<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>看不见的html标签 | 仲灏小栈</title>
    <meta name="generator" content="VuePress 1.9.5">
    <link rel="icon" href="/img/favicon.ico">
    <meta name="description" content="专注web全栈学习与总结。JavaScript,js,ES6,TypeScript,vue,python,css3,html5,Node,git,github等技术文章。">
    <meta name="keywords" content="前端博客,个人技术博客,前端,前端开发,前端框架,web前端,前端面试题,技术文档,学习,面试,JavaScript,js,ES6,TypeScript,vue,python,css3,html5,Node,git,github,markdown">
    <meta name="baidu-site-verification" content="code-5CGlqw1B4p">
    <meta name="google-site-verification" content="PbO8RiLRwDnNwqNFNGnaxZnEFB3CqcGMCGoloYfQXV0">
    <meta name="theme-color" content="#65d1a0">
    
    <link rel="preload" href="/assets/css/0.styles.6c1f7aaa.css" as="style"><link rel="preload" href="/assets/js/app.6d26e8d4.js" as="script"><link rel="preload" href="/assets/js/2.8273876b.js" as="script"><link rel="preload" href="/assets/js/9.c942e82a.js" as="script"><link rel="prefetch" href="/assets/js/10.cb095657.js"><link rel="prefetch" href="/assets/js/100.fbcd69a7.js"><link rel="prefetch" href="/assets/js/101.8fad45f8.js"><link rel="prefetch" href="/assets/js/102.16b0b3d1.js"><link rel="prefetch" href="/assets/js/103.c2af4d4a.js"><link rel="prefetch" href="/assets/js/104.d37d4660.js"><link rel="prefetch" href="/assets/js/105.27e54103.js"><link rel="prefetch" href="/assets/js/106.e4098682.js"><link rel="prefetch" href="/assets/js/107.8efeef5d.js"><link rel="prefetch" href="/assets/js/108.6c305bbf.js"><link rel="prefetch" href="/assets/js/109.6f1c6613.js"><link rel="prefetch" href="/assets/js/11.d1f39b42.js"><link rel="prefetch" href="/assets/js/110.6f264ba6.js"><link rel="prefetch" href="/assets/js/111.1b6294ef.js"><link rel="prefetch" href="/assets/js/112.2ad16154.js"><link rel="prefetch" href="/assets/js/113.a40acefc.js"><link rel="prefetch" href="/assets/js/114.d44cb107.js"><link rel="prefetch" href="/assets/js/115.bd15b919.js"><link rel="prefetch" href="/assets/js/116.778a9058.js"><link rel="prefetch" href="/assets/js/117.19ff15b7.js"><link rel="prefetch" href="/assets/js/118.2630ca8d.js"><link rel="prefetch" href="/assets/js/119.604bd439.js"><link rel="prefetch" href="/assets/js/12.892c0d9f.js"><link rel="prefetch" href="/assets/js/120.43a964f8.js"><link rel="prefetch" href="/assets/js/121.5993f55a.js"><link rel="prefetch" href="/assets/js/122.6c054fcf.js"><link rel="prefetch" href="/assets/js/123.95ddd9a3.js"><link rel="prefetch" href="/assets/js/124.c3a9510e.js"><link rel="prefetch" href="/assets/js/125.612c461a.js"><link rel="prefetch" href="/assets/js/126.ccdb194e.js"><link rel="prefetch" href="/assets/js/127.865789a0.js"><link rel="prefetch" href="/assets/js/128.9e0bc723.js"><link rel="prefetch" href="/assets/js/129.68515ee6.js"><link rel="prefetch" href="/assets/js/13.ea744146.js"><link rel="prefetch" href="/assets/js/130.32a31759.js"><link rel="prefetch" href="/assets/js/131.467e7aaf.js"><link rel="prefetch" href="/assets/js/132.3bb05df9.js"><link rel="prefetch" href="/assets/js/133.52bbf931.js"><link rel="prefetch" href="/assets/js/134.ee00e869.js"><link rel="prefetch" href="/assets/js/135.aadd30fb.js"><link rel="prefetch" href="/assets/js/136.6b5bb775.js"><link rel="prefetch" href="/assets/js/137.9d66b052.js"><link rel="prefetch" href="/assets/js/138.1df874a9.js"><link rel="prefetch" href="/assets/js/139.bd1e48e9.js"><link rel="prefetch" href="/assets/js/14.c755eadf.js"><link rel="prefetch" href="/assets/js/140.2a849d58.js"><link rel="prefetch" href="/assets/js/141.28c22cf9.js"><link rel="prefetch" href="/assets/js/142.e99735ee.js"><link rel="prefetch" href="/assets/js/143.0666fdce.js"><link rel="prefetch" href="/assets/js/144.216c1efe.js"><link rel="prefetch" href="/assets/js/145.fad2c93a.js"><link rel="prefetch" href="/assets/js/146.01533714.js"><link rel="prefetch" href="/assets/js/147.1af38e50.js"><link rel="prefetch" href="/assets/js/148.84844c3d.js"><link rel="prefetch" href="/assets/js/149.49ce06ed.js"><link rel="prefetch" href="/assets/js/15.7a29d3f4.js"><link rel="prefetch" href="/assets/js/150.234bdfef.js"><link rel="prefetch" href="/assets/js/151.89e0796a.js"><link rel="prefetch" href="/assets/js/152.389ced87.js"><link rel="prefetch" href="/assets/js/153.07285920.js"><link rel="prefetch" href="/assets/js/154.965fc5c1.js"><link rel="prefetch" href="/assets/js/155.7bf58a9a.js"><link rel="prefetch" href="/assets/js/156.99e400e4.js"><link rel="prefetch" href="/assets/js/157.b6edd5ab.js"><link rel="prefetch" href="/assets/js/158.af656e52.js"><link rel="prefetch" href="/assets/js/159.4b3d37d2.js"><link rel="prefetch" href="/assets/js/16.5c417580.js"><link rel="prefetch" href="/assets/js/160.fa1e9d1b.js"><link rel="prefetch" href="/assets/js/161.43d6f2b4.js"><link rel="prefetch" href="/assets/js/162.c0e7e60f.js"><link rel="prefetch" href="/assets/js/163.c78d27b4.js"><link rel="prefetch" href="/assets/js/164.7ee2986b.js"><link rel="prefetch" href="/assets/js/165.bbc6516b.js"><link rel="prefetch" href="/assets/js/166.90e15253.js"><link rel="prefetch" href="/assets/js/167.18578ca6.js"><link rel="prefetch" href="/assets/js/168.c52ad494.js"><link rel="prefetch" href="/assets/js/169.c34b2d53.js"><link rel="prefetch" href="/assets/js/17.76fdc3b2.js"><link rel="prefetch" href="/assets/js/170.c97f6096.js"><link rel="prefetch" href="/assets/js/171.358f0f02.js"><link rel="prefetch" href="/assets/js/172.30f03133.js"><link rel="prefetch" href="/assets/js/173.b72d5243.js"><link rel="prefetch" href="/assets/js/174.4e333643.js"><link rel="prefetch" href="/assets/js/175.2c07b836.js"><link rel="prefetch" href="/assets/js/176.29bcb24c.js"><link rel="prefetch" href="/assets/js/177.102b3f0f.js"><link rel="prefetch" href="/assets/js/178.5862bde0.js"><link rel="prefetch" href="/assets/js/179.0da54072.js"><link rel="prefetch" href="/assets/js/18.f857e697.js"><link rel="prefetch" href="/assets/js/180.393e8099.js"><link rel="prefetch" href="/assets/js/181.418f9fe8.js"><link rel="prefetch" href="/assets/js/182.e65424fa.js"><link rel="prefetch" href="/assets/js/183.3b3cb092.js"><link rel="prefetch" href="/assets/js/184.73f7a76a.js"><link rel="prefetch" href="/assets/js/185.537623fb.js"><link rel="prefetch" href="/assets/js/186.df802468.js"><link rel="prefetch" href="/assets/js/187.1095bafd.js"><link rel="prefetch" href="/assets/js/188.1d2acd1a.js"><link rel="prefetch" href="/assets/js/189.dc6a5186.js"><link rel="prefetch" href="/assets/js/19.8c1d0f81.js"><link rel="prefetch" href="/assets/js/190.a279b4dd.js"><link rel="prefetch" href="/assets/js/191.3abaa15f.js"><link rel="prefetch" href="/assets/js/192.4d0dd04e.js"><link rel="prefetch" href="/assets/js/193.2c698e6f.js"><link rel="prefetch" href="/assets/js/194.4243beaa.js"><link rel="prefetch" href="/assets/js/195.7c13b124.js"><link rel="prefetch" href="/assets/js/196.b18118bf.js"><link rel="prefetch" href="/assets/js/197.2abfac38.js"><link rel="prefetch" href="/assets/js/198.407f0a8b.js"><link rel="prefetch" href="/assets/js/199.d4e97578.js"><link rel="prefetch" href="/assets/js/20.47831bf7.js"><link rel="prefetch" href="/assets/js/200.86ce407c.js"><link rel="prefetch" href="/assets/js/201.56a65a3f.js"><link rel="prefetch" href="/assets/js/202.f852c6e8.js"><link rel="prefetch" href="/assets/js/203.92530d7a.js"><link rel="prefetch" href="/assets/js/204.ce612269.js"><link rel="prefetch" href="/assets/js/205.b14b2d70.js"><link rel="prefetch" href="/assets/js/206.b5112828.js"><link rel="prefetch" href="/assets/js/207.a4becd8a.js"><link rel="prefetch" href="/assets/js/208.f82e2766.js"><link rel="prefetch" href="/assets/js/209.11566ec8.js"><link rel="prefetch" href="/assets/js/21.8580b0b4.js"><link rel="prefetch" href="/assets/js/210.bf848e0e.js"><link rel="prefetch" href="/assets/js/211.6db52324.js"><link rel="prefetch" href="/assets/js/212.c9a03071.js"><link rel="prefetch" href="/assets/js/213.734c775f.js"><link rel="prefetch" href="/assets/js/214.7654a416.js"><link rel="prefetch" href="/assets/js/215.34ad7e3d.js"><link rel="prefetch" href="/assets/js/216.aabcd184.js"><link rel="prefetch" href="/assets/js/217.26ffe7d6.js"><link rel="prefetch" href="/assets/js/218.d8ceaf2e.js"><link rel="prefetch" href="/assets/js/219.82bad7ef.js"><link rel="prefetch" href="/assets/js/22.2d87ea68.js"><link rel="prefetch" href="/assets/js/220.0c35dcdf.js"><link rel="prefetch" href="/assets/js/221.8657d7c1.js"><link rel="prefetch" href="/assets/js/222.291af8a7.js"><link rel="prefetch" href="/assets/js/223.e8ce5ce0.js"><link rel="prefetch" href="/assets/js/224.2c3c1268.js"><link rel="prefetch" href="/assets/js/225.b31429da.js"><link rel="prefetch" href="/assets/js/226.8ec29e66.js"><link rel="prefetch" href="/assets/js/227.84469b41.js"><link rel="prefetch" href="/assets/js/228.cd6b9967.js"><link rel="prefetch" href="/assets/js/229.e5497c23.js"><link rel="prefetch" href="/assets/js/23.c1a929a6.js"><link rel="prefetch" href="/assets/js/230.643fdbb6.js"><link rel="prefetch" href="/assets/js/231.22457248.js"><link rel="prefetch" href="/assets/js/232.7e94e6f0.js"><link rel="prefetch" href="/assets/js/233.1083085e.js"><link rel="prefetch" href="/assets/js/234.6ce5972b.js"><link rel="prefetch" href="/assets/js/235.bc1d1e7e.js"><link rel="prefetch" href="/assets/js/236.f510d892.js"><link rel="prefetch" href="/assets/js/237.4690c583.js"><link rel="prefetch" href="/assets/js/238.ef69b085.js"><link rel="prefetch" href="/assets/js/239.e7cbaef4.js"><link rel="prefetch" href="/assets/js/24.707a9b9d.js"><link rel="prefetch" href="/assets/js/240.02e1ce4d.js"><link rel="prefetch" href="/assets/js/241.8ccdecd0.js"><link rel="prefetch" href="/assets/js/242.25a5eeac.js"><link rel="prefetch" href="/assets/js/243.80dc6cf3.js"><link rel="prefetch" href="/assets/js/244.d2d264c1.js"><link rel="prefetch" href="/assets/js/245.8646c059.js"><link rel="prefetch" href="/assets/js/246.0d788a8c.js"><link rel="prefetch" href="/assets/js/247.211b425b.js"><link rel="prefetch" href="/assets/js/248.15e5b430.js"><link rel="prefetch" href="/assets/js/249.b28c41d2.js"><link rel="prefetch" href="/assets/js/25.e47a8360.js"><link rel="prefetch" href="/assets/js/250.e4621bbf.js"><link rel="prefetch" href="/assets/js/251.2f49ea1d.js"><link rel="prefetch" href="/assets/js/252.c567824c.js"><link rel="prefetch" href="/assets/js/253.7eb2a6c2.js"><link rel="prefetch" href="/assets/js/254.adf8b2ad.js"><link rel="prefetch" href="/assets/js/255.43d07402.js"><link rel="prefetch" href="/assets/js/256.d49b01ff.js"><link rel="prefetch" href="/assets/js/257.cc61cd1a.js"><link rel="prefetch" href="/assets/js/258.e46ee926.js"><link rel="prefetch" href="/assets/js/259.5c84c742.js"><link rel="prefetch" href="/assets/js/26.db56ba8d.js"><link rel="prefetch" href="/assets/js/260.05cc8cff.js"><link rel="prefetch" href="/assets/js/261.1891f9c6.js"><link rel="prefetch" href="/assets/js/262.0913812a.js"><link rel="prefetch" href="/assets/js/263.a6836819.js"><link rel="prefetch" href="/assets/js/264.363da610.js"><link rel="prefetch" href="/assets/js/265.2cbfbe9f.js"><link rel="prefetch" href="/assets/js/266.555ca792.js"><link rel="prefetch" href="/assets/js/267.83f4c202.js"><link rel="prefetch" href="/assets/js/268.6dea35af.js"><link rel="prefetch" href="/assets/js/269.cbc5306b.js"><link rel="prefetch" href="/assets/js/27.0b0c1f7f.js"><link rel="prefetch" href="/assets/js/270.6bc430c5.js"><link rel="prefetch" href="/assets/js/271.f5105765.js"><link rel="prefetch" href="/assets/js/272.e1541ef7.js"><link rel="prefetch" href="/assets/js/273.158c7593.js"><link rel="prefetch" href="/assets/js/274.efb98c5b.js"><link rel="prefetch" href="/assets/js/275.cf2c3b21.js"><link rel="prefetch" href="/assets/js/276.0bf20a2d.js"><link rel="prefetch" href="/assets/js/277.2e4ddf6c.js"><link rel="prefetch" href="/assets/js/278.7f8b14ac.js"><link rel="prefetch" href="/assets/js/279.83a65d2f.js"><link rel="prefetch" href="/assets/js/28.a5d8ae18.js"><link rel="prefetch" href="/assets/js/280.47de1643.js"><link rel="prefetch" href="/assets/js/281.1d5cab51.js"><link rel="prefetch" href="/assets/js/282.b2299bce.js"><link rel="prefetch" href="/assets/js/283.fdad201b.js"><link rel="prefetch" href="/assets/js/284.cdf83f8f.js"><link rel="prefetch" href="/assets/js/285.caee6eb0.js"><link rel="prefetch" href="/assets/js/286.6b211023.js"><link rel="prefetch" href="/assets/js/287.e9e93db3.js"><link rel="prefetch" href="/assets/js/288.5892d2e1.js"><link rel="prefetch" href="/assets/js/289.48074c49.js"><link rel="prefetch" href="/assets/js/29.0bc8ea25.js"><link rel="prefetch" href="/assets/js/290.b478b2ab.js"><link rel="prefetch" href="/assets/js/291.18239d2b.js"><link rel="prefetch" href="/assets/js/292.9f6b48b4.js"><link rel="prefetch" href="/assets/js/293.70a0b924.js"><link rel="prefetch" href="/assets/js/294.bc5f021a.js"><link rel="prefetch" href="/assets/js/295.dfa72324.js"><link rel="prefetch" href="/assets/js/296.fb717477.js"><link rel="prefetch" href="/assets/js/297.2b2daf25.js"><link rel="prefetch" href="/assets/js/298.0ed3ce25.js"><link rel="prefetch" href="/assets/js/299.c59a3f82.js"><link rel="prefetch" href="/assets/js/3.d68e1d13.js"><link rel="prefetch" href="/assets/js/30.063f8dbe.js"><link rel="prefetch" href="/assets/js/300.f423c130.js"><link rel="prefetch" href="/assets/js/301.a11bcaa5.js"><link rel="prefetch" href="/assets/js/302.5a45b99e.js"><link rel="prefetch" href="/assets/js/303.80ac16da.js"><link rel="prefetch" href="/assets/js/304.f773afc2.js"><link rel="prefetch" href="/assets/js/305.52f1b3ba.js"><link rel="prefetch" href="/assets/js/306.966f2eef.js"><link rel="prefetch" href="/assets/js/307.c22143cf.js"><link rel="prefetch" href="/assets/js/308.a6dfec6e.js"><link rel="prefetch" href="/assets/js/309.377e4f0b.js"><link rel="prefetch" href="/assets/js/31.69d8f2c2.js"><link rel="prefetch" href="/assets/js/310.a76309fc.js"><link rel="prefetch" href="/assets/js/311.0706d5ca.js"><link rel="prefetch" href="/assets/js/312.40513d91.js"><link rel="prefetch" href="/assets/js/313.e36621af.js"><link rel="prefetch" href="/assets/js/314.3d4325be.js"><link rel="prefetch" href="/assets/js/315.72480163.js"><link rel="prefetch" href="/assets/js/316.83f31163.js"><link rel="prefetch" href="/assets/js/317.872fd713.js"><link rel="prefetch" href="/assets/js/318.0dc2aea4.js"><link rel="prefetch" href="/assets/js/319.454e4745.js"><link rel="prefetch" href="/assets/js/32.50aa541b.js"><link rel="prefetch" href="/assets/js/320.d9116236.js"><link rel="prefetch" href="/assets/js/321.b06a7a4e.js"><link rel="prefetch" href="/assets/js/322.41bcaaf1.js"><link rel="prefetch" href="/assets/js/323.f01ba88b.js"><link rel="prefetch" href="/assets/js/324.9a736f30.js"><link rel="prefetch" href="/assets/js/325.49b1193e.js"><link rel="prefetch" href="/assets/js/326.5a07b4a0.js"><link rel="prefetch" href="/assets/js/327.aceece56.js"><link rel="prefetch" href="/assets/js/328.e03489c3.js"><link rel="prefetch" href="/assets/js/329.5673fdef.js"><link rel="prefetch" href="/assets/js/33.4aa00ff3.js"><link rel="prefetch" href="/assets/js/330.246e74fa.js"><link rel="prefetch" href="/assets/js/331.e1cffa6b.js"><link rel="prefetch" href="/assets/js/332.2856b83e.js"><link rel="prefetch" href="/assets/js/333.d4c9c15a.js"><link rel="prefetch" href="/assets/js/334.13b03971.js"><link rel="prefetch" href="/assets/js/335.0b8ed702.js"><link rel="prefetch" href="/assets/js/336.3e71f28d.js"><link rel="prefetch" href="/assets/js/337.f929f08c.js"><link rel="prefetch" href="/assets/js/338.01a6cfbe.js"><link rel="prefetch" href="/assets/js/339.5cd647ad.js"><link rel="prefetch" href="/assets/js/34.b25c4a87.js"><link rel="prefetch" href="/assets/js/340.f941cae0.js"><link rel="prefetch" href="/assets/js/341.aa01a6b1.js"><link rel="prefetch" href="/assets/js/342.edd59a58.js"><link rel="prefetch" href="/assets/js/343.237c716b.js"><link rel="prefetch" href="/assets/js/344.06e59f2b.js"><link rel="prefetch" href="/assets/js/345.ddd4f6fe.js"><link rel="prefetch" href="/assets/js/346.70fe3c42.js"><link rel="prefetch" href="/assets/js/347.d39ad15e.js"><link rel="prefetch" href="/assets/js/348.1b135410.js"><link rel="prefetch" href="/assets/js/349.fd78d783.js"><link rel="prefetch" href="/assets/js/35.a1af8744.js"><link rel="prefetch" href="/assets/js/350.b10e7d69.js"><link rel="prefetch" href="/assets/js/351.a6ae4318.js"><link rel="prefetch" href="/assets/js/352.3117739a.js"><link rel="prefetch" href="/assets/js/353.99e022f1.js"><link rel="prefetch" href="/assets/js/354.a444c2d8.js"><link rel="prefetch" href="/assets/js/355.13d044aa.js"><link rel="prefetch" href="/assets/js/356.d2cfe5d0.js"><link rel="prefetch" href="/assets/js/357.eb44f05f.js"><link rel="prefetch" href="/assets/js/358.394c15db.js"><link rel="prefetch" href="/assets/js/359.6c541551.js"><link rel="prefetch" href="/assets/js/36.5558b717.js"><link rel="prefetch" href="/assets/js/360.65af88d5.js"><link rel="prefetch" href="/assets/js/361.d9b3c889.js"><link rel="prefetch" href="/assets/js/362.37ec0a7d.js"><link rel="prefetch" href="/assets/js/363.49690222.js"><link rel="prefetch" href="/assets/js/364.419b3dab.js"><link rel="prefetch" href="/assets/js/365.1f79df07.js"><link rel="prefetch" href="/assets/js/366.fa710c6f.js"><link rel="prefetch" href="/assets/js/367.497eeda5.js"><link rel="prefetch" href="/assets/js/368.45cf08f6.js"><link rel="prefetch" href="/assets/js/369.80a60b6a.js"><link rel="prefetch" href="/assets/js/37.511798d2.js"><link rel="prefetch" href="/assets/js/370.61b161b4.js"><link rel="prefetch" href="/assets/js/371.545f0249.js"><link rel="prefetch" href="/assets/js/372.d383f896.js"><link rel="prefetch" href="/assets/js/373.df22361b.js"><link rel="prefetch" href="/assets/js/374.0b9872ee.js"><link rel="prefetch" href="/assets/js/375.76bbca97.js"><link rel="prefetch" href="/assets/js/376.1f6f8210.js"><link rel="prefetch" href="/assets/js/377.3dd0dc75.js"><link rel="prefetch" href="/assets/js/378.32cac01d.js"><link rel="prefetch" href="/assets/js/379.6682a524.js"><link rel="prefetch" href="/assets/js/38.2dfd8d32.js"><link rel="prefetch" href="/assets/js/380.1ab9ec1d.js"><link rel="prefetch" href="/assets/js/381.cea4ec7d.js"><link rel="prefetch" href="/assets/js/382.fc51cce1.js"><link rel="prefetch" href="/assets/js/383.489718b4.js"><link rel="prefetch" href="/assets/js/384.a7a1c6d7.js"><link rel="prefetch" href="/assets/js/385.7b2d3a89.js"><link rel="prefetch" href="/assets/js/386.f0a18324.js"><link rel="prefetch" href="/assets/js/387.53063e56.js"><link rel="prefetch" href="/assets/js/388.1115759c.js"><link rel="prefetch" href="/assets/js/389.58bf8aaf.js"><link rel="prefetch" href="/assets/js/39.e8482eab.js"><link rel="prefetch" href="/assets/js/4.de17fbe4.js"><link rel="prefetch" href="/assets/js/40.c6dc3476.js"><link rel="prefetch" href="/assets/js/41.78bfe256.js"><link rel="prefetch" href="/assets/js/42.248cddd4.js"><link rel="prefetch" href="/assets/js/43.6429d3dc.js"><link rel="prefetch" href="/assets/js/44.71e9af05.js"><link rel="prefetch" href="/assets/js/45.f80fb4fc.js"><link rel="prefetch" href="/assets/js/46.3d5e7e58.js"><link rel="prefetch" href="/assets/js/47.1bbf5e9a.js"><link rel="prefetch" href="/assets/js/48.6909050b.js"><link rel="prefetch" href="/assets/js/49.9c775f82.js"><link rel="prefetch" href="/assets/js/5.59910585.js"><link rel="prefetch" href="/assets/js/50.aceb6009.js"><link rel="prefetch" href="/assets/js/51.acd0d321.js"><link rel="prefetch" href="/assets/js/52.a4f9f157.js"><link rel="prefetch" href="/assets/js/53.0f1ec943.js"><link rel="prefetch" href="/assets/js/54.6c5c2837.js"><link rel="prefetch" href="/assets/js/55.f412714f.js"><link rel="prefetch" href="/assets/js/56.64a3862c.js"><link rel="prefetch" href="/assets/js/57.d070eb7d.js"><link rel="prefetch" href="/assets/js/58.a80067c8.js"><link rel="prefetch" href="/assets/js/59.084f5e76.js"><link rel="prefetch" href="/assets/js/6.0ab71a58.js"><link rel="prefetch" href="/assets/js/60.42e0fbb5.js"><link rel="prefetch" href="/assets/js/61.b5b87c23.js"><link rel="prefetch" href="/assets/js/62.014cdbe2.js"><link rel="prefetch" href="/assets/js/63.ff1278d1.js"><link rel="prefetch" href="/assets/js/64.44a86cb2.js"><link rel="prefetch" href="/assets/js/65.1a69bd56.js"><link rel="prefetch" href="/assets/js/66.b8d9a1e9.js"><link rel="prefetch" href="/assets/js/67.48e3c0e6.js"><link rel="prefetch" href="/assets/js/68.127da596.js"><link rel="prefetch" href="/assets/js/69.77e4e1cb.js"><link rel="prefetch" href="/assets/js/7.769e6e3f.js"><link rel="prefetch" href="/assets/js/70.7863bd30.js"><link rel="prefetch" href="/assets/js/71.c5c89c65.js"><link rel="prefetch" href="/assets/js/72.030ac8a4.js"><link rel="prefetch" href="/assets/js/73.e96cf593.js"><link rel="prefetch" href="/assets/js/74.f9319fe7.js"><link rel="prefetch" href="/assets/js/75.049ce9e1.js"><link rel="prefetch" href="/assets/js/76.c71e5605.js"><link rel="prefetch" href="/assets/js/77.1e682453.js"><link rel="prefetch" href="/assets/js/78.0cce7473.js"><link rel="prefetch" href="/assets/js/79.3d32f303.js"><link rel="prefetch" href="/assets/js/8.812618a5.js"><link rel="prefetch" href="/assets/js/80.c956dc30.js"><link rel="prefetch" href="/assets/js/81.8276eaa8.js"><link rel="prefetch" href="/assets/js/82.10f6fdc6.js"><link rel="prefetch" href="/assets/js/83.cac65ec1.js"><link rel="prefetch" href="/assets/js/84.a4ce0ebf.js"><link rel="prefetch" href="/assets/js/85.d9efee67.js"><link rel="prefetch" href="/assets/js/86.cf64260c.js"><link rel="prefetch" href="/assets/js/87.e261e385.js"><link rel="prefetch" href="/assets/js/88.63b9894b.js"><link rel="prefetch" href="/assets/js/89.0ad95e30.js"><link rel="prefetch" href="/assets/js/90.77f9f729.js"><link rel="prefetch" href="/assets/js/91.3fcbf2d5.js"><link rel="prefetch" href="/assets/js/92.8b57334e.js"><link rel="prefetch" href="/assets/js/93.6095e56a.js"><link rel="prefetch" href="/assets/js/94.c616143f.js"><link rel="prefetch" href="/assets/js/95.a9b61cf9.js"><link rel="prefetch" href="/assets/js/96.a3896e7e.js"><link rel="prefetch" href="/assets/js/97.0318332c.js"><link rel="prefetch" href="/assets/js/98.17b8173b.js"><link rel="prefetch" href="/assets/js/99.d299c156.js">
    <link rel="stylesheet" href="/assets/css/0.styles.6c1f7aaa.css">
  </head>
  <body class="theme-mode-light">
    <div id="app" data-server-rendered="true"><div class="theme-container sidebar-open have-rightmenu have-body-img"><header class="navbar blur"><div title="目录" class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="/img/logo.png" alt="仲灏小栈" class="logo"> <span class="site-name can-hide">仲灏小栈</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><a href="/web/" class="nav-link">大前端</a></div><div class="nav-item"><a href="/backend-opt/" class="nav-link">后端&amp;运维</a></div><div class="nav-item"><a href="/other-tech/" class="nav-link">其他技术</a></div><div class="nav-item"><a href="/tech-live/" class="nav-link">生活</a></div><div class="nav-item"><a href="/about/" class="nav-link">关于我</a></div><div class="nav-item"><a href="/favorite/" class="nav-link">收藏</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="索引" class="dropdown-title"><a href="/archives/" class="link-title">索引</a> <span class="title" style="display:none;">索引</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/" class="nav-link">分类</a></li><li class="dropdown-item"><!----> <a href="/tags/" class="nav-link">标签</a></li><li class="dropdown-item"><!----> <a href="/archives/" class="nav-link">归档</a></li></ul></div></div> <a href="https://github.com/izhaong" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <div class="sidebar-hover-trigger"></div> <aside class="sidebar" style="display:none;"><div class="blogger"><img src="https://cdn.jsdelivr.net/gh/izhaong/izhaong.com-oss/site-data/avatar/avatar-wx.jpg"> <div class="blogger-info"><h3>仲灏</h3> <span>诚意, 正心, 格物, 致知</span></div></div> <nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><a href="/web/" class="nav-link">大前端</a></div><div class="nav-item"><a href="/backend-opt/" class="nav-link">后端&amp;运维</a></div><div class="nav-item"><a href="/other-tech/" class="nav-link">其他技术</a></div><div class="nav-item"><a href="/tech-live/" class="nav-link">生活</a></div><div class="nav-item"><a href="/about/" class="nav-link">关于我</a></div><div class="nav-item"><a href="/favorite/" class="nav-link">收藏</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="索引" class="dropdown-title"><a href="/archives/" class="link-title">索引</a> <span class="title" style="display:none;">索引</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/" class="nav-link">分类</a></li><li class="dropdown-item"><!----> <a href="/tags/" class="nav-link">标签</a></li><li class="dropdown-item"><!----> <a href="/archives/" class="nav-link">归档</a></li></ul></div></div> <a href="https://github.com/izhaong" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav>  <ul class="sidebar-links"><li><a href="/note/infrastructure/" class="sidebar-link">《前端项目基础建设》</a></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>HTML&amp;CSS</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/pages/1110/" class="sidebar-link">Scss语言学习实用心得</a></li><li><a href="/pages/15af70/" class="sidebar-link">H5 标签使用场景</a></li><li><a href="/pages/03a46d/" class="sidebar-link">css常用命名单词</a></li><li><a href="/pages/e1f868/" class="sidebar-link">项目基础建设 css与处理器scss</a></li><li><a href="/pages/b189f2/" class="sidebar-link">项目基础建设 CSS公共样式</a></li><li><a href="/pages/10481f/" class="sidebar-link">iframe</a></li><li><a href="/pages/749ce2/" class="sidebar-link">css 变量使用</a></li><li><a href="/pages/14d171/" class="sidebar-link">css常见但不常用的属性</a></li><li><a href="/pages/dbb200/" class="sidebar-link">躺着旋转动画</a></li><li><a href="/pages/7e3052/" class="sidebar-link">边框渐变（圆形）</a></li><li><a href="/pages/3aded5/" class="sidebar-link">float 布局</a></li><li><a href="/pages/2a8bd5/" class="sidebar-link">在 Javascript 和 Sass（或 CSS！）之间共享变量的方法</a></li><li><a href="/pages/d3debc/" aria-current="page" class="active sidebar-link">看不见的html标签</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/pages/7499ea/" class="sidebar-link">手写css预处理器</a></li><li><a href="/pages/933422/" class="sidebar-link">grid vs flex布局</a></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>JavaScript&amp;TypeScript</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>Node</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>构建</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>Vue</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>React</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>小程序</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>跨端</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>Electron</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>WebGL&amp;GIS</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>浏览器</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>面经</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>其他</span> <span class="arrow right"></span></p> <!----></section></li></ul> </aside> <div><main class="page"><div class="theme-vdoing-wrapper "><div class="articleInfo-wrap" data-v-06225672><div class="articleInfo" data-v-06225672><ul class="breadcrumbs" data-v-06225672><li data-v-06225672><a href="/" title="首页" class="iconfont icon-home router-link-active" data-v-06225672></a></li> <li data-v-06225672><a href="/web/#大前端" data-v-06225672>大前端</a></li><li data-v-06225672><a href="/web/#HTML&amp;CSS" data-v-06225672>HTML&amp;CSS</a></li></ul> <div class="info" data-v-06225672><div title="作者" class="author iconfont icon-touxiang" data-v-06225672><a href="https://github.com/izhaong" target="_blank" title="作者" class="beLink" data-v-06225672>仲灏</a></div> <div title="创建时间" class="date iconfont icon-riqi" data-v-06225672><a href="javascript:;" data-v-06225672>2022-10-31</a></div> <!----></div></div></div> <!----> <div class="content-wrapper"><div class="right-menu-wrapper"><div class="right-menu-margin"><div class="right-menu-title">目录</div> <div class="right-menu-content"></div></div></div> <h1><img src="">看不见的html标签<!----></h1>  <div class="theme-vdoing-content content__default"><p>有一些非常重要却容易被忽视的标签，这些标签大多数用在页面头部 head 标签内，虽然对用户不可见，但如果在某些场景下，比如交互实现、性能优化、搜索优化，合理利用它们就可以达到事半功倍的效果。</p> <p>看看那些“看不见”的 HTML 标签及其使用场景。</p> <h3 id="交互实现"><a href="#交互实现" class="header-anchor">#</a> 交互实现</h3> <h4 id="meta-标签-自动刷新-跳转"><a href="#meta-标签-自动刷新-跳转" class="header-anchor">#</a> meta 标签：自动刷新/跳转</h4> <p><em>很多人都是第一印象使用定时器或者<code>node-schedule</code> 库来实现</em></p> <p>假设要实现一个类似 PPT 自动播放的效果，你很可能会想到使用 JavaScript 定时器控制页面跳转来实现。但其实有更加简洁的实现方法，比如通过 meta 标签来实现：</p> <div class="language-html line-numbers-mode"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">http-equiv</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>Refresh<span class="token punctuation">&quot;</span></span> <span class="token attr-name">content</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>5; URL=page2.html<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>上面的代码会在 5s 之后自动跳转到同域下的 page2.html 页面。我们要实现 PPT 自动播放的功能，只需要在每个页面的 meta 标签内设置好下一个页面的地址即可。</p> <p>另一种场景，比如每隔一分钟就需要刷新页面的大屏幕监控，也可以通过 meta 标签来实现，只需去掉后面的 URL 即可：</p> <div class="language-html line-numbers-mode"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">http-equiv</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>Refresh<span class="token punctuation">&quot;</span></span> <span class="token attr-name">content</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>60<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>在使用它的时候，刷新和跳转操作是不可取消的，所以对刷新时间间隔或者需要手动取消的，还是推荐使用 JavaScript 定时器来实现。</p> <p>如果你只是想实现页面的定时刷新或跳转（比如某些页面缺乏访问权限，在 x 秒后跳回首页这样的场景）建议你可以实践下 meta 标签的用法。</p> <h4 id="title-标签与-hack-手段-消息提醒"><a href="#title-标签与-hack-手段-消息提醒" class="header-anchor">#</a> title 标签与 Hack 手段：消息提醒</h4> <p>作为前端工程师的你对 B/S 架构肯定不陌生，它有很多的优点，比如版本更新方便、跨平台、跨终端，但在处理某些场景，比如即时通信场景时，就会变得比较麻烦。</p> <p>因为前后端通信深度依赖 HTTP 协议，而 HTTP 协议采用“请求-响应”模式，这就决定了服务端也只能被动地发送数据。一种低效的解决方案是客户端通过轮询机制获取最新消息（HTML5 下可使用 WebSocket 协议）。</p> <p>消息提醒功能实现则比较困难，HTML5 标准发布之前，浏览器没有开放图标闪烁、弹出系统消息之类的接口，只能借助一些 Hack 的手段，比如修改 title 标签来达到类似的效果（HTML5 下可使用 Web Notifications API 弹出系统消息）。</p> <p>下面这段代码中，通过定时修改 title 标签内容，模拟了类似消息提醒的闪烁效果：</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token keyword">let</span> msgNum <span class="token operator">=</span> <span class="token number">1</span> <span class="token comment">// 消息条数</span>
<span class="token keyword">let</span> cnt <span class="token operator">=</span> <span class="token number">0</span> <span class="token comment">// 计数器</span>
<span class="token keyword">const</span> inerval <span class="token operator">=</span> <span class="token function">setInterval</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
  cnt <span class="token operator">=</span> <span class="token punctuation">(</span>cnt <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">%</span> <span class="token number">2</span>
  <span class="token keyword">if</span><span class="token punctuation">(</span>msgNum<span class="token operator">===</span><span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token comment">// 通过DOM修改title</span>
    document<span class="token punctuation">.</span>title <span class="token operator">+=</span> <span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">聊天页面</span><span class="token template-punctuation string">`</span></span>
    <span class="token function">clearInterval</span><span class="token punctuation">(</span>interval<span class="token punctuation">)</span>
    <span class="token keyword">return</span>
  <span class="token punctuation">}</span>
  <span class="token keyword">const</span> prefix <span class="token operator">=</span> cnt <span class="token operator">%</span> <span class="token number">2</span> <span class="token operator">?</span> <span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">新消息(</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>msgNum<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">)</span><span class="token template-punctuation string">`</span></span> <span class="token operator">:</span> <span class="token string">''</span>
  document<span class="token punctuation">.</span>title <span class="token operator">=</span> <span class="token template-string"><span class="token template-punctuation string">`</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>prefix<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">聊天页面</span><span class="token template-punctuation string">`</span></span>
<span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token number">1000</span><span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br></div></div><p>实现效果如下图所示，可以看到标签名称上有提示文字在闪烁。</p> <p><img src="https://cdn.jsdelivr.net/gh/izhaong/izhaong.com-oss/blogImg/1010100.%E4%B8%8D%E5%B8%B8%E7%94%A8html%E6%A0%87%E7%AD%BE%E4%BD%BF%E7%94%A8/2022/11/01/17-10-29-8b9f4498520122e5e17e421438d752a9-CgqCHl65LJGAR25PAAAXBLXRFXg133-9e6c07.gif" alt="categories.gif"></p> <p>通过模拟消息闪烁，可以让用户在浏览其他页面的时候，及时得知服务端返回的消息。</p> <p>定时修改 title 标签内容，除了用来实现闪烁效果之外，还可以制作其他动画效果，比如文字滚动，但需要注意浏览器会对 title 标签文本进行去空格操作。</p> <p>动态修改 title 标签的用途不仅在于消息提醒，你还可以将一些关键信息显示到标签上（比如下载时的进度、当前操作步骤），从而提升用户体验。</p> <h3 id="性能优化"><a href="#性能优化" class="header-anchor">#</a> 性能优化</h3> <p>性能优化是前端开发中避不开的问题，性能问题无外乎两方面原因：渲染速度慢、请求时间长。性能优化虽然涉及很多复杂的原因和解决方案，但其实只要通过合理地使用标签，就可以在一定程度上提升渲染速度以及减少请求时间。</p> <h4 id="script-标签-调整加载顺序提升渲染速度"><a href="#script-标签-调整加载顺序提升渲染速度" class="header-anchor">#</a> script 标签：调整加载顺序提升渲染速度</h4> <p>由于浏览器的底层运行机制，渲染引擎在解析 HTML 时，若遇到 script 标签引用文件，则会暂停解析过程，同时通知网络线程加载文件，文件加载后会切换至 JavaScript 引擎来执行对应代码，代码执行完成之后切换至渲染引擎继续渲染页面。</p> <p>在这一过程中可以看到，页面渲染过程中包含了请求文件以及执行文件的时间，但页面的首次渲染可能并不依赖这些文件，这些请求和执行文件的动作反而延长了用户看到页面的时间，从而降低了用户体验。</p> <p>为了减少这些时间损耗，可以借助 script 标签的 3 个属性来实现。</p> <ul><li><strong>async 属性</strong>。立即请求文件，但不阻塞渲染引擎，而是文件加载完毕后阻塞渲染引擎并立即执行文件内容。</li> <li><strong>defer 属性</strong>。立即请求文件，但不阻塞渲染引擎，等到解析完 HTML 之后再执行文件内容。</li> <li><strong>HTML5 标准 type 属性</strong>，对应值为“module”。让浏览器按照 ECMA Script 6 标准将文件当作模块进行解析，默认阻塞效果同 defer，也可以配合 async 在请求完成后立即执行。</li></ul> <p>具体效果可以参看下图：</p> <p><img src="/Users/izhaong/izhaong/Project_me/Blog/izhaong.com-localFile/1010100.%E4%B8%8D%E5%B8%B8%E7%94%A8html%E6%A0%87%E7%AD%BE%E4%BD%BF%E7%94%A8/Ciqc1F647iiAZx3cAAB1ewBzlh0431.png" alt="1583465393011-810652f489ca6136.png"></p> <p>其中，绿色的线表示执行解析 HTML ，蓝色的线表示请求文件，红色的线表示执行文件。</p> <p>从图中可以得知，采用 3 种属性都能减少请求文件引起的阻塞时间，只有 defer 属性以及 type=&quot;module&quot; 情况下能保证渲染引擎的优先执行，从而减少执行文件内容消耗的时间，让用户更快地看见页面（即使这些页面内容可能并没有完全地显示）。</p> <p>除此之外还应当注意，当渲染引擎解析 HTML 遇到 script 标签引入文件时，会立即进行一次渲染。所以这也就是为什么构建工具会把编译好的引用 JavaScript 代码的 script 标签放入到 body 标签底部，因为当渲染引擎执行到 body 底部时会先将已解析的内容渲染出来，然后再去请求相应的 JavaScript 文件。如果是内联脚本（即不通过 src 属性引用外部脚本文件直接在 HTML 编写 JavaScript 代码的形式），渲染引擎则不会渲染。</p> <h4 id="link-标签-通过预处理提升渲染速度"><a href="#link-标签-通过预处理提升渲染速度" class="header-anchor">#</a> link 标签：通过预处理提升渲染速度</h4> <p>在我们对大型单页应用进行性能优化时，也许会用到按需懒加载的方式，来加载对应的模块，但如果能合理利用 link 标签的 rel 属性值来进行预加载，就能进一步提升渲染速度。</p> <ul><li><strong>dns-prefetch</strong>。当 link 标签的 rel 属性值为“dns-prefetch”时，浏览器会对某个域名预先进行 DNS 解析并缓存。这样，当浏览器在请求同域名资源的时候，能省去从域名查询 IP 的过程，从而减少时间损耗。下图是淘宝网设置的 DNS 预解析。</li></ul> <p><img src="https://cdn.jsdelivr.net/gh/izhaong/izhaong.com-oss/blogImg/1010100.%E4%B8%8D%E5%B8%B8%E7%94%A8html%E6%A0%87%E7%AD%BE%E4%BD%BF%E7%94%A8/2022/11/01/17-36-13-d469706c5871eea00e5831b5dcb1e3c6-Ciqc1F647jWAHmc_AAAiNGoHmY8154-ccf8c3.png" alt="1583466667742-993b502f80fa3567.png"></p> <ul><li><strong>preconnect</strong>。让浏览器在一个 HTTP 请求正式发给服务器前预先执行一些操作，这包括 DNS 解析、TLS 协商、TCP 握手，通过消除往返延迟来为用户节省时间。</li> <li><strong>prefetch/preload</strong>。两个值都是让浏览器预先下载并缓存某个资源，但不同的是，prefetch 可能会在浏览器忙时被忽略，而 preload 则是一定会被预先下载。</li> <li><strong>prerender</strong>。浏览器不仅会加载资源，还会解析执行页面，进行预渲染。</li></ul> <p>这几个属性值恰好反映了浏览器获取资源文件的过程，在这里我绘制了一个流程简图，方便你记忆。</p> <p><img src="https://cdn.jsdelivr.net/gh/izhaong/izhaong.com-oss/blogImg/1010100.%E4%B8%8D%E5%B8%B8%E7%94%A8html%E6%A0%87%E7%AD%BE%E4%BD%BF%E7%94%A8/2022/11/01/17-35-57-efcb22ea804514a535ce9c9cf376c1cd-Ciqc1F647j-AFiBtAABWh7ld3uA965-90ddc2.png" alt="1583470467405-1d2eb8baf7568d31.png"></p> <p>浏览器获取资源文件的流程</p> <h3 id="搜索优化"><a href="#搜索优化" class="header-anchor">#</a> 搜索优化</h3> <p>你所写的前端代码，除了要让浏览器更好执行，有时候也要考虑更方便其他程序（如搜索引擎）理解。合理地使用 meta 标签和 link 标签，恰好能让搜索引擎更好地理解和收录我们的页面。</p> <h4 id="meta-标签-提取关键信息"><a href="#meta-标签-提取关键信息" class="header-anchor">#</a> meta 标签：提取关键信息</h4> <p>通过 meta 标签可以设置页面的描述信息，从而让搜索引擎更好地展示搜索结果。</p> <p>例如，在百度中搜索“拉勾”，就会发现网站的描述信息，这些描述信息就是通过 meta 标签专门为搜索引擎设置的，目的是方便用户预览搜索到的结果。</p> <p><img src="https://cdn.jsdelivr.net/gh/izhaong/izhaong.com-oss/blogImg/1010100.%E4%B8%8D%E5%B8%B8%E7%94%A8html%E6%A0%87%E7%AD%BE%E4%BD%BF%E7%94%A8/2022/11/01/17-37-17-0e6d2fe23b1e8513d062b9ffcd2c2503-Ciqc1F647kmAMJF6AABXM1K7WdY483-fe65a5.png" alt="1583481178981-737e6b76d555f457.png"></p> <p>为了让搜索引擎更好地识别页面，除了描述信息之外还可以使用关键字，这样即使页面其他地方没有包含搜索内容，也可以被搜索到（当然搜索引擎有自己的权重和算法，如果滥用关键字是会被降权的，比如 Google 引擎就会对堆砌大量相同关键词的网页进行惩罚，降低它被搜索到的权重）。</p> <p>当我们搜索关键字“垂直互联网招聘”的时候搜索结果会显示拉勾网的信息，虽然显示的搜索内容上并没有看到“垂直互联网招聘”字样，这就是因为拉勾网页面中设置了这个关键字。</p> <p><img src="https://cdn.jsdelivr.net/gh/izhaong/izhaong.com-oss/blogImg/1010100.%E4%B8%8D%E5%B8%B8%E7%94%A8html%E6%A0%87%E7%AD%BE%E4%BD%BF%E7%94%A8/2022/11/01/17-37-15-611df63a9984ca169b92daf352bb0998-Ciqc1F647lSAGbePAAEeMKqCVgw178-42af65.png" alt="1583481543840-ce4f715602d1b084.png"></p> <p>对应代码如下：</p> <div class="language-html line-numbers-mode"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">content</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>拉勾,拉勾网,拉勾招聘,拉钩, 拉钩网 ,互联网招聘,拉勾互联网招聘, 移动互联网招聘, 垂直互联网招聘, 微信招聘, 微博招聘, 拉勾官网, 拉勾百科,跳槽, 高薪职位, 互联网圈子, IT招聘, 职场招聘, 猎头招聘,O2O招聘, LBS招聘, 社交招聘, 校园招聘, 校招,社会招聘,社招<span class="token punctuation">&quot;</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>keywords<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>在实际工作中，推荐使用一些关键字工具来挑选，比如 <a href="https://trends.google.com/trends" target="_blank" rel="noopener noreferrer">Google Trends<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>、<a href="https://data.chinaz.com/keyword/" target="_blank" rel="noopener noreferrer">站长工具<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>。下图是我使用站长工具搜索“招聘”关键字得到的结果，可以看到得到了相当关键的一些信息，比如全网搜索指数、关键词特点。</p> <p><img src="https://cdn.jsdelivr.net/gh/izhaong/izhaong.com-oss/blogImg/1010100.%E4%B8%8D%E5%B8%B8%E7%94%A8html%E6%A0%87%E7%AD%BE%E4%BD%BF%E7%94%A8/2022/11/01/17-39-00-ed9413138e3177a145d768c3dce40b8f-CgqCHl647l2Abd9XAAEL0O2drYw681-c07df1.png" alt="image.png"></p> <h4 id="link-标签-减少重复"><a href="#link-标签-减少重复" class="header-anchor">#</a> link 标签：减少重复</h4> <p>有时候为了用户访问方便或者出于历史原因，对于同一个页面会有多个网址，又或者存在某些重定向页面，比如：</p> <ul><li><a href="https://edu.lagou.com/" target="_blank" rel="noopener noreferrer">https://lagou.com/a.html<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="https://edu.lagou.com/" target="_blank" rel="noopener noreferrer">https://lagou.com/detail?id=<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>&quot;abcd&quot;</li></ul> <p>那么在这些页面中可以这样设置：</p> <div class="language-html line-numbers-mode"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>link</span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>https://lagou.com/a.html<span class="token punctuation">&quot;</span></span> <span class="token attr-name">rel</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>canonical<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>这样可以让搜索引擎避免花费时间抓取重复网页。不过需要注意的是，它还有个限制条件，那就是指向的网站不允许跨域。</p> <p>当然，要合并网址还有其他的方式，比如使用站点地图，或者在 HTTP 请求响应头部添加 rel=&quot;canonical&quot;。这里，我就不展开介绍了，道理都是相通的，你平时可以多探索和实践。</p> <h3 id="延伸内容-ogp-开放图表协议"><a href="#延伸内容-ogp-开放图表协议" class="header-anchor">#</a> 延伸内容：OGP（开放图表协议）</h3> <p><img src="https://cdn.jsdelivr.net/gh/izhaong/izhaong.com-oss/blogImg/1010100.%E4%B8%8D%E5%B8%B8%E7%94%A8html%E6%A0%87%E7%AD%BE%E4%BD%BF%E7%94%A8/2022/11/01/17-44-10-799a003d8cc0d69bd222164d2d506d32-Ciqc1F65LLeAZf33AAAvMXPozlk099-4ee32e.png" alt="1583483633365-97ac0eb2d1c6d7d2.png"></p> <p>好了，前面我们说了 HTML5 标准的一些标签和属性，下面再延伸说一说基于 meta 标签扩展属性值实现的第三方协议——OGP（Open Graph Protocal，开放图表协议 ）。</p> <p>OGP 是 Facebook 公司在 2010 年提出的，目的是通过增加文档信息来提升社交网页在被分享时的预览效果。你只需要在一些分享页面中添加一些 meta 标签及属性，支持 OGP 协议的社交网站就会在解析页面时生成丰富的预览信息，比如站点名称、网页作者、预览图片。具体预览效果会因各个网站而有所变化。</p> <p>下面是微信文章支持 OGP 协议的代码，可以看到通过 meta 标签属性值声明了：网址、预览图片、描述信息、站点名称、网页类型和作者信息。</p> <p><img src="https://cdn.jsdelivr.net/gh/izhaong/izhaong.com-oss/blogImg/1010100.%E7%9C%8B%E4%B8%8D%E8%A7%81%E7%9A%84html%E6%A0%87%E7%AD%BE/2022/11/01/17-42-42-ec3a177ccc4ad368e94feb7618e9bc56-CgqCHl647neAc1fJAACYggDXkeE601-2e3cac.png" alt="1583480543843-477274458e5be00b.png"></p> <p>现在百度已经宣布支持，微信文章的不少页面上也添加了相关标签属性，有兴趣的话你可以查看官方网站：https://ogp.me/。</p> <h3 id="总结"><a href="#总结" class="header-anchor">#</a> 总结</h3> <p>交互实现、性能优化、搜索优化场景出发，</p> <p>分别讲解了 meta 标签、title 标签、link 标签，以及 script 标签在这些场景中的重要作用</p></div></div>  <div class="page-edit"><!----> <!----> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">2022/11/09, 11:51:56</span></div></div> <div class="page-nav-wapper"><div class="page-nav-centre-wrap"><a href="/pages/2a8bd5/" class="page-nav-centre page-nav-centre-prev"><div class="tooltip">在 Javascript 和 Sass（或 CSS！）之间共享变量的方法</div></a> <a href="/pages/7499ea/" class="page-nav-centre page-nav-centre-next"><div class="tooltip">手写css预处理器</div></a></div> <div class="page-nav"><p class="inner"><span class="prev">
        ←
        <a href="/pages/2a8bd5/" class="prev">在 Javascript 和 Sass（或 CSS！）之间共享变量的方法</a></span> <span class="next"><a href="/pages/7499ea/">手写css预处理器</a>→
      </span></p></div></div></div> <div class="article-list"><div class="article-title"><a href="/archives/" class="iconfont icon-bi">最近更新</a></div> <div class="article-wrapper"><dl><dd>01</dd> <dt><a href="/pages/e3ef00/"><div>
            接雨水
            <!----></div></a> <span class="date">04-08</span></dt></dl><dl><dd>02</dd> <dt><a href="/pages/a5eeb6/"><div>
            vim日常使用记录
            <!----></div></a> <span class="date">04-08</span></dt></dl><dl><dd>03</dd> <dt><a href="/pages/d46779/"><div>
            有效的字母异位词
            <!----></div></a> <span class="date">04-08</span></dt></dl> <dl><dd></dd> <dt><a href="/archives/" class="more">更多文章&gt;</a></dt></dl></div></div></main></div> <div class="footer"><div class="icons"><a href="mailto:izhaong@outlook.com" title="发邮件" target="_blank" class="iconfont icon-youjian"></a><a href="https://github.com/izhaong" title="GitHub" target="_blank" class="iconfont icon-github"></a><a href="https://music.163.com/#/playlist?id=755597173" title="听音乐" target="_blank" class="iconfont icon-erji"></a></div> 
  Theme by
  <a href="https://github.com/xugaoyi/vuepress-theme-vdoing" target="_blank" title="本站主题">Vdoing</a> 
    | Copyright © 2021-2024
    <span>izhaong | <a href="https://github.com/izhaong" target="_blank">github</a> | <a href="http://beian.miit.gov.cn/" target="_blank">蜀ICP备2021031194号</a></span></div> <div class="buttons"><div title="返回顶部" class="button blur go-to-top iconfont icon-fanhuidingbu" style="display:none;"></div> <div title="去评论" class="button blur go-to-comment iconfont icon-pinglun" style="display:none;"></div> <div title="主题模式" class="button blur theme-mode-but iconfont icon-zhuti"><ul class="select-box" style="display:none;"><li class="iconfont icon-zidong">
          跟随系统
        </li><li class="iconfont icon-rijianmoshi">
          浅色模式
        </li><li class="iconfont icon-yejianmoshi">
          深色模式
        </li><li class="iconfont icon-yuedu">
          阅读模式
        </li></ul></div></div> <div class="body-bg" style="background:url() center center / cover no-repeat;opacity:0.5;"></div> <!----> <!----></div><div class="global-ui"><div></div></div></div>
    <script src="/assets/js/app.6d26e8d4.js" defer></script><script src="/assets/js/2.8273876b.js" defer></script><script src="/assets/js/9.c942e82a.js" defer></script>
  </body>
</html>
